from pattern.circuit import Control


class entry(Control):

    DEFAULT_REPLY = ":%(username)s!%(user)s PART :%(channel)s\r\n"

    def incoming(self, event):
        channel = event.data[0][0]
        username = event.trail.username
        self.onPart(event, channel.split(","), username)
        #event.trail.wfile.write(self.DEFAULT_REPLY \
        #                        % {'channel': channel,
        #                           'username': username,
        #                           'user': username + "!here",
        #                           'servername': "localhost"})

    def onPart(self, event, channels, username):
        bridge = self.acquireInterface(event, "onPart")
        if bridge is not None:
            bridge.push("part", channels, username)
